package com.feng.gameproj;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ScreenInfoActivity extends Activity 
{
	private Button change = null;
	private TextView width = null;
	private TextView height = null;
	
	private static final int full_screen = WindowManager.LayoutParams.FLAG_FULLSCREEN;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		/*设置全屏幕显示  必须在add Content之前调用*/
		requestWindowFeature (Window.FEATURE_NO_TITLE); // 无标题栏
		getWindow().setFlags (full_screen, full_screen); // 设为全屏模式
		
		setContentView (R.layout.screen_info);
		
		this.width = (TextView)findViewById (R.id.screen_width);
		this.height = (TextView)findViewById (R.id.screen_height);
		
		this.change = (Button)findViewById (R.id.change_screen);
		this.change.setOnClickListener (new ChangeScreenListener ());
		
		/*获取屏幕信息*/
		DisplayMetrics dm = new DisplayMetrics ();
		getWindowManager ().getDefaultDisplay ().getMetrics(dm);
		
		int swidth = dm.widthPixels;
		int sheight = dm.heightPixels;
		this.width.setText("Screen Width: " + swidth);
		this.height.setText("Screen Height: " + sheight);
		
	}
	
	class ChangeScreenListener implements OnClickListener
	{
		@Override
		public void onClick(View v) 
		{
			//int orientation = getRequestedOrientation();
			/*切换屏幕显示方向*/
			//if (orientation == ActivityInfo.s)
			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
		}
	}

}
